﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Linq;

namespace Scoreboard.Model
{
	public partial class Stage
	{
		public IEnumerable<Group> OrderedGroups
		{
			get
			{ 
				return Groups.OrderBy(g => g.IndexNumber); 
			}
		}

		public bool ContainsGroups
		{
			get
			{
				return Groups != null && Groups.Count > 0;
			}
		}

		public bool IsUniform
		{
			get
			{	
				if (Groups.Count != 2)
				{
					return true;
				}

				var firstGroupSize = (double)Groups.First().Participants.Count;
				var secondGroupSize = (double)Groups.Last().Participants.Count;

				var relation = firstGroupSize / secondGroupSize;
				if (relation < 0.8 || relation > 1.2)
				{
					return false;
				}
				return true;
			}
		}
	}
}
